using CopyPP;
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Net;
using System.Windows.Forms;
namespace soft917ecom
{
	public class ValidCode : Form
	{
		private Button button2;
		private PictureBox picbVC;
		private Label label17;
		public TextBox txtVC;
		private Container container_0;
		private Button button1;
		private Button button3;
		public string url = "";
		public ValidCode(string msg, string imgurl)
		{
			this.InitializeComponent();
			this.url = imgurl;
			this.Text = msg;
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.container_0 != null)
			{
				this.container_0.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(ValidCode));
			this.button2 = new Button();
			this.picbVC = new PictureBox();
			this.label17 = new Label();
			this.txtVC = new TextBox();
			this.button1 = new Button();
			this.button3 = new Button();
			((ISupportInitialize)this.picbVC).BeginInit();
			base.SuspendLayout();
			this.button2.Font = new Font("宋体", 9f, FontStyle.Bold, GraphicsUnit.Point, 134);
			this.button2.ForeColor = Color.Green;
			this.button2.Location = new Point(160, 8);
			this.button2.Name = "button2";
			this.button2.Size = new Size(56, 53);
			this.button2.TabIndex = 17;
			this.button2.Text = "看不清换一个";
			this.button2.Click += new EventHandler(this.button2_Click);
			this.picbVC.Location = new Point(8, 8);
			this.picbVC.Name = "picbVC";
			this.picbVC.Size = new Size(130, 53);
			this.picbVC.TabIndex = 16;
			this.picbVC.TabStop = false;
			this.label17.AutoSize = true;
			this.label17.Location = new Point(8, 72);
			this.label17.Name = "label17";
			this.label17.Size = new Size(77, 12);
			this.label17.TabIndex = 19;
			this.label17.Text = "输入验证码：";
			this.txtVC.Location = new Point(88, 68);
			this.txtVC.Name = "txtVC";
			this.txtVC.Size = new Size(128, 21);
			this.txtVC.TabIndex = 0;
			this.txtVC.TextChanged += new EventHandler(this.txtVC_TextChanged);
			this.button1.Location = new Point(8, 96);
			this.button1.Name = "button1";
			this.button1.Size = new Size(88, 24);
			this.button1.TabIndex = 20;
			this.button1.Text = "停止收藏";
			this.button1.Visible = false;
			this.button1.Click += new EventHandler(this.button1_Click);
			this.button3.Location = new Point(120, 96);
			this.button3.Name = "button3";
			this.button3.Size = new Size(88, 24);
			this.button3.TabIndex = 21;
			this.button3.Text = "退出软件";
			this.button3.Click += new EventHandler(this.button3_Click);
			this.AutoScaleBaseSize = new Size(6, 14);
			base.ClientSize = new Size(224, 125);
			base.ControlBox = false;
			base.Controls.Add(this.button3);
			base.Controls.Add(this.button1);
			base.Controls.Add(this.label17);
			base.Controls.Add(this.txtVC);
			base.Controls.Add(this.button2);
			base.Controls.Add(this.picbVC);
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "ValidCode";
			base.StartPosition = FormStartPosition.CenterParent;
			this.Text = "登录验证码";
			base.Load += new EventHandler(this.ValidCode_Load);
			base.Closing += new CancelEventHandler(this.ValidCode_Closing);
			((ISupportInitialize)this.picbVC).EndInit();
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		private void ValidCode_Closing(object sender, CancelEventArgs e)
		{
		}
		private void ValidCode_Load(object sender, EventArgs e)
		{
			Form1 form = (Form1)base.Owner;
			if (this.url.Length < 2)
			{
				base.Left = form.Left + 20;
				return;
			}
			string requestUriString = this.url;
			HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUriString);
			httpWebRequest.CookieContainer = form.cookie;
			HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
			form.cookie.Add(httpWebResponse.Cookies);
			Stream responseStream = httpWebResponse.GetResponseStream();
			this.picbVC.Image = new Bitmap(responseStream);
			responseStream.Close();
			this.txtVC.Focus();
		}
		private void button2_Click(object sender, EventArgs e)
		{
			Form1 form = (Form1)base.Owner;
			DateTime dateTime = new DateTime(1970, 1, 1);
			string str = ((DateTime.Now.Ticks - dateTime.Ticks) / 10000L).ToString();
			string requestUriString = this.url + "&r=" + str;
			HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUriString);
			httpWebRequest.CookieContainer = form.cookie;
			HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
			form.cookie.Add(httpWebResponse.Cookies);
			Stream responseStream = httpWebResponse.GetResponseStream();
			this.picbVC.Image = new Bitmap(responseStream);
			responseStream.Close();
			this.txtVC.Focus();
		}
		private void txtVC_TextChanged(object sender, EventArgs e)
		{
			if (this.txtVC.Text.Length > 3)
			{
				Form1 form = (Form1)base.Owner;
				form.vcinput = this.txtVC.Text.ToUpper();
				base.DialogResult = DialogResult.OK;
			}
		}
		private void button3_Click(object sender, EventArgs e)
		{
			Form1 form = (Form1)base.Owner;
			form.ExitApp();
			base.Close();
		}
		private void button1_Click(object sender, EventArgs e)
		{
			Form1 arg_0B_0 = (Form1)base.Owner;
			base.Close();
		}
	}
}
